//
//  JianBianViewController.m
//  SensorTagEX
//
//  Created by sno on 15-2-1.
//  Copyright (c) 2015年 Texas Instruments. All rights reserved.
//

#import "JianBianViewController.h"
#import "CmdData.h"
#import "BLEUtility.h"
@interface JianBianViewController ()
@property (weak, nonatomic) IBOutlet UILabel *mlabTime;
@property (weak, nonatomic) IBOutlet UISlider *mSlider;

@end

@implementation JianBianViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    _mSlider.minimumValue=1;
    _mSlider.maximumValue=255;
    _second=1;
    _isOpen=NO;
 
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (IBAction)jianbianSwitch:(UISwitch *)sender {
    _isOpen=sender.isOn;
    NSData *data=[CmdData getJianBianArray:_isOpen second:_second
     ];
    
    [BLEUtility writeData:data];
}
- (IBAction)valueChanged:(UISlider *)sender {
    if(_isOpen)
    {        int no = (int)(sender.value + 0.5);
        NSLog(@"send is %d",no);
        _second=no;
        float fsec=(float)no;
        
        NSString *str=[NSString stringWithFormat:@"%.1f秒",fsec/2];
        _mlabTime.text=str;
        //        NSData *data=[CmdData getJianBianArray:_isOpen second:_second];
//        [BLEUtility writeData:data];
    }
}
- (IBAction)btnSendData:(id)sender {
    NSData *data=[CmdData getJianBianArray:_isOpen second:_second];
        [BLEUtility writeData:data];
}

@end
